#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    picId = 1;
    QPixmap pix("/home/eleven/Pictures/Screenshots/1.png");
    ui->label->setPixmap(pix);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_startbutton_clicked()
{
    myTimerId = this->startTimer(TIMEOUT);

}

void Widget::timerEvent(QTimerEvent *event)
{
    if (event->timerId() != myTimerId)
    {
        return;
    }
    QString path("/home/eleven/Pictures/Screenshots/");
    path += QString::number(picId);
    path += ".png";
    QPixmap pix(path);
    ui->label->setPixmap(pix);
    picId++;
    if (5 == picId)
    {
        picId = 1;
    }

}

void Widget::on_stopbutton_clicked()
{
    this->killTimer(myTimerId);
}

